<template>
  <div>
    <imp-info :fields="fields" @toSubmit="toSubmit"/>
  </div>
</template>

<script>
import api from '@/api'
import impInfo from '@/components/impInfo'
export default {
  name: 'teacher-imp-info',
  data () {
    return {
      name: '',
      city: '',
      china_id: '', // 传递的城市code
      show: false,
      fileList: [],
      file: '',
      addrCode: '440105',
      fields: [
        {label: '企业名', key: 'name', type: 'input'},
        {label: '所在城市', key: 'location', type: 'address'}
      ]
    }
  },
  mounted () {
    // this.getCitys()
  },
  created () {
  },
  components: {
    impInfo
  },
  methods: {
    onAddrConfirm (e) { // 点击确认，获取所选的省市区数据
      console.log('this.onAddrConfirm=>e', e)
      this.show = false
      this.province = e[0].name
      this.city = e[1].name
      this.china_id = e[1].code
      console.log(this.china_id)
    },
    shut () { // 点击取消
      this.show = false
    },
    // getCitys () {
    //   api.getImpInfo({
    //     params: {},
    //     callback: res => {
    //       console.log(res.data.data)
    //       // res.data = citys
    //     }
    //   })
    // },
    afterRead (file) {
      this.file = file.file
      console.log(file.file)
    },
    showPopup () {
      this.show = true
    },
    toSubmit (params) {
      let formData = new FormData()
      formData.append('id', JSON.parse(sessionStorage.getItem('user')).id)
      Object.keys(params).forEach(key => {
        formData.append(key, params[key])
      })
      api.agencyPerfectIndividual({
        params: formData,
        callback: res => {
          if (res.data.error_code === 0) {
            this.$router.push('/my/index')
          }
        }
      })
    }
  }
}
</script>

<style scoped>
    .container {
        padding: 0 15px;
    }

    .avatar {
        padding: 50px 0;
        text-align: center;
    }

    .avatar .des {
        font-size: 16px;
        font-family: PingFang SC;
        font-weight: 400;
        line-height: 22px;
        color: rgba(153, 153, 153, 1);
    }

    .avatar p {
        margin-top: 15px;
    }

    .van-field {
        border-bottom: 1px solid #707070;
        padding-left: 0;
        margin-top: 16px;
    }

    .btn {
        margin-top: 70px;
    }
</style>
